package org.cmy.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CallbackController {

    @GetMapping("/callback")
    public String callback(
            @RequestParam(required = false) String code,
            @RequestParam(required = false) String error) {
        System.out.println("回调了");
        if (error != null) {
            return "Authorization error: " + error;
        }
        if (code != null) {
            return "✅ Authorization Code: <b>" + code + "</b><br>" +
                   "Now exchange it for an access token using curl or Postman.";
        }
        return "No code or error received.";
    }
}